fix: use eventType description and booking description correctly in CalendarEvent (#28818)#28864
Conversation
…alendarEvent (calcom#28818) Previously, CalendarEvent.description was incorrectly set to booking.description (attendee notes), and CalendarEvent.additionalNotes was not set at all. This caused confirmation emails to show attendee notes in the description field instead of the event type's description. Changes: - Set CalendarEvent.description to eventType.description (event type's description) - Set CalendarEvent.additionalNotes to booking.description (attendee's notes) - Updated buildCalendarEvent in addGuests.handler.ts - Updated buildCalEventFromBooking in buildCalEventFromBooking.ts - Updated CalendarEvent creation in confirm.handler.ts - Updated CalendarEvent creation in payment/getBooking.ts - Updated tests to verify both fields are set correctly Fixes calcom#28818
📝 WalkthroughWalkthroughThe pull request refactors how event descriptions are handled across the booking system. The 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/trpc/server/routers/viewer/bookings/confirm.handler.ts`:
- Around line 320-321: The object literal in confirm.handler.ts defines
additionalNotes twice causing the later raw assignment additionalNotes:
booking.description to override the earlier normalized additionalNotes:
booking.description || null; remove the duplicate raw assignment
(additionalNotes: booking.description) so only the normalized additionalNotes:
booking.description || null remains (matching buildCalEventFromBooking,
addGuests.handler, getBooking patterns).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7fceabfe-deda-4793-9c2d-f218315c3f75
📒 Files selected for processing (5)
packages/features/bookings/lib/payment/getBooking.tspackages/lib/__tests__/buildCalEventFromBooking.test.tspackages/lib/buildCalEventFromBooking.tspackages/trpc/server/routers/viewer/bookings/addGuests.handler.tspackages/trpc/server/routers/viewer/bookings/confirm.handler.ts
| description: booking.eventType?.description || "", | ||
| additionalNotes: booking.description || null, |
There was a problem hiding this comment.
Duplicate additionalNotes property causes inconsistent behavior.
additionalNotes is assigned twice in this object literal:
- Line 321:
additionalNotes: booking.description || null(normalizes falsy values tonull) - Line 368:
additionalNotes: booking.description(raw value, no normalization)
Since line 368 comes after line 321, it overrides the first assignment. This creates a semantic difference: an empty string "" would be normalized to null on line 321 but passed through as "" on line 368.
This is inconsistent with the other files in this PR (buildCalEventFromBooking.ts, addGuests.handler.ts, getBooking.ts) which all use the || null normalization pattern.
🐛 Proposed fix: Remove the duplicate assignment
...(platformClientParams ? platformClientParams : {}),
organizationId: organizerOrganizationId ?? booking.eventType?.team?.parentId ?? null,
- additionalNotes: booking.description,
assignmentReason: booking.assignmentReason?.[0]?.reasonEnumAlso applies to: 368-368
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/trpc/server/routers/viewer/bookings/confirm.handler.ts` around lines
320 - 321, The object literal in confirm.handler.ts defines additionalNotes
twice causing the later raw assignment additionalNotes: booking.description to
override the earlier normalized additionalNotes: booking.description || null;
remove the duplicate raw assignment (additionalNotes: booking.description) so
only the normalized additionalNotes: booking.description || null remains
(matching buildCalEventFromBooking, addGuests.handler, getBooking patterns).
Summary
Fixes #28818 - Booking confirmation emails now correctly display event type description and attendee notes in their respective fields.
Problem
Confirmation emails were showing attendee notes (booking.description) in the description field instead of the event type's description. The additionalNotes field was never populated.
Solution
CalendarEvent.descriptionnow useseventType.description(event type's description)CalendarEvent.additionalNotesnow usesbooking.description(attendee's booking notes)|| nullfor additionalNotes normalization (not|| undefined)Changes
buildCalendarEvent()inaddGuests.handler.tsbuildCalEventFromBooking()inbuildCalEventFromBooking.tsconfirm.handler.tspayment/getBooking.tsbuildCalEventFromBooking.test.tsTest Plan
Before
After